import request from '@/router/axios';

// 获取所有顶级字典
export const getParentList = (current, size, params) => {
  return request({
    url: '/system/dict-biz/parent-list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

// 获取指定字典的子集字典
export const getChildList = (current, size, parentId, params) => {
  return request({
    url: '/system/dict-biz/child-list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      parentId,
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/system/dict-biz/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/system/dict-biz/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/system/dict-biz/submit',
    method: 'post',
    data: row
  })
}

// 详情
export const getDict = (id) => {
  return request({
    url: '/system/dict-biz/detail',
    method: 'get',
    params: {
      id,
    }
  })
}
export const getDictTree = () => {
  return request({
    url: '/system/dict-biz/tree',
    method: 'get'
  })
}

/**
 * 查询字典
 */
export const getDictionaryAPI = '/system/dict-biz/dictionary'
export const getDictionary = (params) => {
  return request({
    url: getDictionaryAPI,
    method: 'get',
    params,
  })
}